<template>
	<!-- #ifdef MP-WEIXIN -->
	<uv-navbar
	  :fixed="false"
	  :title="title"
	  left-arrow
	  @leftClick="$onClickLeft"
	/>
	<!-- #endif -->
	<view class="p-2">
		<uv-list>
			<uv-list-item :title="currentLanguageTexts.orderAmount"  :rightText="'$'+totalPrice"></uv-list-item>
			<uv-list-item :title="currentLanguageTexts.refundAmount"  :rightText="'$'+payPrice"></uv-list-item>
			<uv-list-item :title="currentLanguageTexts.RefundType"  :rightText="currentLanguageTexts.TheOrder"></uv-list-item>
			<uv-list-item :title="currentLanguageTexts.ReasonRefund"  :rightText="currentLanguageTexts.consensus"></uv-list-item>
			<uv-list-item :title="currentLanguageTexts.RefundMessage" >
				<template #footer><uv-input :placeholder="currentLanguageTexts.PleaseContent" border="none" v-model="refundReasonWapExplain"></uv-input></template>
			</uv-list-item>
		</uv-list>
		<view class="mt-2">
			<uv-button shape="circle" type="error" :plain="true" size="small" :text="currentLanguageTexts.requestRefund" @click="refund()"></uv-button>
		</view>
		<uv-toast ref="toast"></uv-toast>
	</view>
</template>

<script setup>
import {
  ref
} from 'vue'
import { onLoad} from '@dcloudio/uni-app'
import {
  orderRefund
} from '@/api/order'
import { storeToRefs } from 'pinia';
import { useMainStore } from '@/store/store';
const main = useMainStore();
const { currentLanguageTexts } = storeToRefs(main);
const title = ref(currentLanguageTexts.value.requestRefund)
const orderId = ref('')
const payPrice = ref('')
const totalPrice = ref('')
const refundReasonWapExplain = ref('')
const toast = ref()
onLoad((option) => {
	orderId.value = option.orderId
	payPrice.value = option.payPrice
	totalPrice.value = option.totalPrice
})

const refund  = async() => {
	let data = await orderRefund({refundReasonWapExplain:refundReasonWapExplain.value,uni:orderId.value,text:currentLanguageTexts.value.consensus});
	if (data) {
		uni.showToast({
			title: currentLanguageTexts.value.SubmittedSuccessfully,
			icon: 'success'
		})
	}
}

</script>

<style>
</style>